{template 'common/header'}

<ul class="nav nav-tabs">
	<li class="active"><a href="{php echo $this->createWebUrl('refund')}">退款管理</a></li>
</ul>

{if $operation == 'display'}
<div class="main panel panel-default">
	<div class="panel-body table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:15%;">姓名</th>					
					<th style="width:10%;">退款金额</th>
					<th style="width:15%;">提交时间</th>
					<th style="width:15%;">退款原因</th>
					<th style="text-align:right;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $tuikuan}
				<tr>
					<td><span class="label label-info">{$tixian['realname']}</span></td>
					<td>{$tuikuan['refund_price']}</span></td>
					<td>
						{php echo date('Y-m-d H:i:s', $tuikuan['tktime'])}<br />
					</td>
					<td>{$tuikuan['refund_desc']}</td>
					<td style="text-align:right;">
						<a href="{php echo $this->createWebUrl('order',array('op'=>'detail','id'=>$tuikuan['id']))}" class="btn btn-info btn-sm">订单详情</a>
						<a href="javascript:;" class="btn btn-success btn-sm" onclick="out_cash('{$tuikuan['id']}','{$tuikuan['nickname']}','{php echo abs($tuikuan['refund_price'])}元');">同意退款</a>
						<a href="{php echo $this->createWebUrl('refund',array('op'=>'shoudong','id'=>$tuikuan['id']))}" onclick="return confirm('此操作不可恢复，确认吗？');return false;" class="btn btn-success btn-sm">手动确认退款</a>
					</td>
				</tr>
				{/loop}
			</tbody>
		</table>
	</div>
</div>
{$pager}
<script type="text/javascript">

	function out_cash(ids,name,money) {
		require(['jquery', 'util'], function($, u) {
			var content =  '	<div class="form-group">';
				content += '	<h4>退款'+money+'</h4>';
				content += '	</div>';

			var footer =
					'<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>' +
					'<button type="button" class="btn btn-success">确定退款</button>';
			var diaobj = u.dialog(name?name:ids, content, footer);
			diaobj.find('.btn-default').click(function() {
				diaobj.modal('hide');
			});
			diaobj.find('.btn-success').click(function() {
				$.post("{php echo $this->createWebUrl('refund', array('op' => 'outcash'))}",{
					ids:ids,
				},function(resp) {
					if(resp.status==1){
						alert(resp.info);
						location.reload();
					}else{
						alert(resp.info.message);
					}
				});
			});
			diaobj.modal('show');
		});
	}
</script>
{/if}
{template 'common/footer'}